package com.ruoyi.swimming.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.swimming.domian.News;
import com.ruoyi.swimming.domian.SwimmingPool;
import com.ruoyi.swimming.mapper.NewsMapper;
import com.ruoyi.swimming.mapper.SwimmingPoolMapper;
import com.ruoyi.swimming.service.ISwimmingPoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 泳池Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-07-17
 */
@Service
public class SwimmingPoolServiceImpl extends ServiceImpl<SwimmingPoolMapper, SwimmingPool> implements ISwimmingPoolService
{
    @Autowired
    private SwimmingPoolMapper swimmingPoolMapper;

    /**
     * 查询泳池
     * 
     * @param id 泳池ID
     * @return 泳池
     */
    @Override
    public SwimmingPool selectSwimmingPoolById(Long id)
    {
        return swimmingPoolMapper.selectSwimmingPoolById(id);
    }

    /**
     * 查询泳池列表
     * 
     * @param swimmingPool 泳池
     * @return 泳池
     */
    @Override
    public List<SwimmingPool> selectSwimmingPoolList(SwimmingPool swimmingPool)
    {
        return swimmingPoolMapper.selectSwimmingPoolList(swimmingPool);
    }

    /**
     * 新增泳池
     * 
     * @param swimmingPool 泳池
     * @return 结果
     */
    @Override
    public int insertSwimmingPool(SwimmingPool swimmingPool)
    {
        swimmingPool.setCreateTime(DateUtils.getNowDate());
        return swimmingPoolMapper.insert(swimmingPool);
    }

    /**
     * 修改泳池
     * 
     * @param swimmingPool 泳池
     * @return 结果
     */
    @Override
    public int updateSwimmingPool(SwimmingPool swimmingPool)
    {
        swimmingPool.setUpdateTime(DateUtils.getNowDate());
        return swimmingPoolMapper.updateById(swimmingPool);
    }

    /**
     * 批量删除泳池
     * 
     * @param ids 需要删除的泳池ID
     * @return 结果
     */
    @Override
    public int deleteSwimmingPoolByIds(Long[] ids)
    {
        return swimmingPoolMapper.deleteBatchIds(Arrays.asList(ids));
    }

    /**
     * 删除泳池信息
     * 
     * @param id 泳池ID
     * @return 结果
     */
    @Override
    public int deleteSwimmingPoolById(Long id)
    {
        return swimmingPoolMapper.deleteById(id);
    }
}
